package com.duobaoyu.dby.supply.db.entity.order;

import com.baomidou.mybatisplus.annotation.*;
import com.duobaoyu.dby.common.mybatis.base.BaseEntity;
import com.duobaoyu.dby.supply.common.biz.compare.Compare;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 订单信息表
 *
 * @author LY
 * @email 249007302@qq.com
 * @date 2023-09-26 10:42:54
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@ApiModel(value = "订单信息表")
@EqualsAndHashCode(callSuper = true)
@TableName(value = "sc_order", autoResultMap = true)
public class Order extends BaseEntity implements Cloneable{
	private static final long serialVersionUID = 1L;

	/**
	 * 主键ID
	 */
	@TableId(type = IdType.ASSIGN_ID)
	private Long id;
	/**
	 * 渠道编码
	 */
	@ApiModelProperty(value = "渠道编码")
	private String channelCode;
	/**
	 * 渠道子单号
	 */
	@ApiModelProperty(value = "渠道子单号")
	private String channelOrderSn;
	/**
	 * 渠道父单号
	 */
	@ApiModelProperty(value = "渠道父单号")
	private String channelOrderParentSn;
	/**
	 * 渠道交易单号
	 */
	@ApiModelProperty(value = "渠道交易单号")
	private String channelTradeOrderSn;
	/**
	 * 渠道订单实际金额
	 */
	@ApiModelProperty(value = "渠道订单实际金额")
	private BigDecimal channelOrderRealityAmount;
	/**
	 * 渠道订单总金额
	 */
	@ApiModelProperty(value = "渠道订单总金额")
	private BigDecimal channelOrderAmount;
	/**
	 * 渠道预估运费
	 */
	@ApiModelProperty(value = "渠道预估运费")
	private BigDecimal channelFreightAmount;
	/**
	 * 渠道实际运费
	 */
	@ApiModelProperty(value = "渠道实际运费")
	private BigDecimal channelActualFreightAmount;
	/**
	 * 供应链三方交易单号
	 */
	@ApiModelProperty(value = "供应链三方交易单号")
	private String orderTradeSn;
	/**
	 * 订单总金额
	 */
	@ApiModelProperty(value = "订单总金额")
	private BigDecimal orderAmount;
	/**
	 * 订单类型,real:实物订单、call:话费快充订单、flow:流量订单、coupon:卡密订单、recharge:直充订单、
	 * call_slow:话费慢充订单、electricity_fees:电费订单、electricity_fees_slow:电费慢充订单
	 * //@see com.duobaoyu.dby.channel.adapter.enums.biz.order.OrderTypeEnum
	 */
	@ApiModelProperty(value = "订单类型,real:实物订单、call:话费快充订单、flow:流量订单、coupon:卡密订单、recharge:直充订单、" +
			" call_slow:话费慢充订单、electricity_fees:电费订单、electricity_fees_slow:电费慢充订单")
	private String orderType;
	/**
	 * 业务订单交易号(与供应链订单号一一对应)
	 */
	@ApiModelProperty(value = "业务订单交易号(与供应链订单号一一对应)")
	private String bizTradeSn;
	/**
	 * 供应链交易单号(与业务订单号一一对应)
	 */
	@ApiModelProperty(value = "供应链交易单号(与业务订单号一一对应)")
	private String supplyTradeSn;
	/**
	 * 供应链订单号
	 */
	@ApiModelProperty(value = "供应链订单号")
	private String orderSn;
	/**
	 * 供应链订单号父单号
	 */
	@ApiModelProperty(value = "供应链订单号父单号")
	private String orderParentSn;
	/**
	 * 0 代表拆分前订单 1代表拆分后订单
	 */
	@ApiModelProperty(value = "0 代表拆分前订单 1代表拆分后订单")
	private Integer parentType;
	/**
	 * 系统内部名称
	 */
	@ApiModelProperty(value = "系统内部名称")
	private String serverName;
	/**
	 * 展示来源渠道
	 */
	@ApiModelProperty(value = "展示来源渠道")
	private String showServerName;
	/**
	 * 手机号/充值账号
	 */
	@ApiModelProperty(value = "手机号/充值账号")
	private String rechargeAccount;
	/**
	 * 下单失败原因
	 */
	@Compare("失败原因")
	@ApiModelProperty(value = "下单失败原因")
	private String failReason;
	/**
	 * 取消原因
	 */
	@ApiModelProperty(value = "取消原因")
	private String cancelReason;
	/**
	 * 备注信息
	 */
	@ApiModelProperty(value = "备注信息")
	private String orderRemark;
	/**
	 * 1 未开票 2 开票中 3已开票， 4开票失败
	 */
	private Integer invoiceStatus;
	/**
	 * 订单状态
	 */
	@Compare("订单状态")
	@ApiModelProperty(value = "订单状态")
	private Integer orderStatus;
	/**
	 * 订单标签: asyn-异步;sync-同步
	 */
	@ApiModelProperty(value = "订单标签: asyn-异步;sync-同步")
	private String orderTag;
	/**
	 * 确认订单时间
	 */
	@ApiModelProperty(value = "确认订单时间")
	private LocalDateTime confirmOrderTime;
	/**
	 * 是否允许请求售后
	 */
	@ApiModelProperty(value = "是否允许请求售后")
	private Boolean afterSalesAllowed;
	/**
	 * 商户ID
	 */
	@ApiModelProperty(value = "商户ID")
	private String mchId;
	/**
	 * 用户ID
	 */
	@ApiModelProperty(value = "用户ID")
	private String userId;
	/**
	 * 状态变更时间
	 */
	@ApiModelProperty(value = "状态变更时间")
	private LocalDateTime statusChangeTime;

	/**
	 * 操作备注
	 */
	@ApiModelProperty(value = "操作备注")
	private String operateRemark;

	/**
	 * 版本号-用作乐观锁
	 */
	@Version
	@ApiModelProperty(value = "版本号-用作乐观锁")
	private Integer version;
	/**
	 * 是否删除 0-否 1-是
	 */
	@TableLogic(value = "0", delval = "1")
	@ApiModelProperty(value = "是否删除 0-否 1-是")
	private Integer delFlag;

	@Override
	public Order clone() {
		try {
			return (Order)super.clone();
		}catch (Exception e){
			return null;
		}
	}
}
